Skip to content

Fix Snyk undici critical/high issues and media href hardening - #251

Merged
Luen merged 2 commits into
mainfrom
fix/snyk-undici-picomatch
Nov 2, 2026
Merged

Luen merged 2 commits into
mainfrom
fix/snyk-undici-picomatch

Conversation

@Luen

@Luen Luen commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Pin undici to ^7.30.1 via npm/pnpm overrides so cheerio no longer pulls vulnerable 7.30.0 (clears the 2 critical + 6 high Snyk findings).
  • Ignore SNYK-JS-PICOMATCH-21248802 in .snyk until an npm release exists; picomatch is only used at build time through next-sitemap/fast-glob with developer-controlled patterns.
  • Route media coverage links through toAbsoluteHttpUrl (and sanitize load-more API items) so href values are protocol-checked and rebuilt from URL components.

Test plan

  • pnpm install resolves undici@7.30.1
  • pnpm run lint
  • pnpm run test
  • pnpm run build
  • Confirm Snyk Open Source project drops to 0 critical / 0 high after retest (picomatch ignored via policy)
  • Spot-check /media links still open correctly

Made with Cursor

Pin undici to ^7.30.1 (cheerio transitive), document the unfixed picomatch ReDoS in .snyk, and route media links through toAbsoluteHttpUrl.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
rummerlab Ready Ready Preview Nov 2, 2026 11:22pm UTC

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Claude BugBot Analysis

No bugs found in the changes. The media URL handling now goes through the shared toAbsoluteHttpUrl helper, and the dependency bumps and .snyk ignore entry look consistent.

No bugs were detected in this PR.

@Luen Luen left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: dependency changes look right (pnpm why undici → only cheerio > undici@7.30.1; picomatch is reached via next-sitemap/fast-glob and the eslint/vitest toolchain only, so the .snyk ignore rationale holds). Two things to tidy before merge, which I will push as a follow-up commit:

  1. toAbsoluteHttpUrl same-origin branch returns the raw input. Any value starting with / is passed through untouched, but browsers resolve /\evil.com and /<TAB>/evil.com to https://evil.com/. That contradicts the new "never reuse the raw input string" comment and lets a crafted path escape to another origin (this helper also guards Scholar-sourced team links). Fix: resolve against a sentinel base, reject if the origin changes, return pathname + search + hash, and add tests.
  2. Double sanitisation in MediaCoverageList. Items are sanitised into state via sanitizeMediaItem and again at render via toAbsoluteHttpUrl(article.url). The render-time check at the href sink is sufficient; dropping sanitizeMediaItem keeps a single source of truth.

Comment thread lib/external-url.ts
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return null;
return parsed.toString();
// Rebuild from URL components so callers never reuse the raw input string.
return `${parsed.protocol}//${parsed.host}${parsed.pathname}${parsed.search}${parsed.hash}`;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rebuild is good, but the earlier candidate.startsWith('/') branch still returns the raw string. new URL('/\evil.com', base) and a /+TAB+/evil.com value both resolve to https://evil.com/, so those become cross-origin links. Suggest resolving same-origin paths against a sentinel base and returning only pathname + search + hash when the origin is unchanged.

Comment thread app/media/MediaCoverageList.tsx Outdated
initialOffset?: number;
};

const sanitizeMediaItem = (item: MediaItem): MediaItem => ({

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant with the render-time toAbsoluteHttpUrl(article.url) below (and sources aren't covered here anyway; SourceTag sanitises those at render). Suggest removing sanitizeMediaItem and keeping the check at the href sink only.

Paths like `/\evil.com` or `/<tab>/evil.com` were returned raw, but browsers
resolve them to another origin. Resolve same-origin paths against a sentinel
base and return only pathname/search/hash when the origin is unchanged. Drop
the redundant sanitizeMediaItem pass; the href sink already sanitises.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Claude BugBot Analysis

No bugs found. The same-origin path check in toAbsoluteHttpUrl correctly rejects /\host and /<tab>/host by resolving them against a dummy base. The MediaCoverageList and MediaSourceTags changes call it correctly, and the rest of the diff is dependency and Snyk metadata bumps.

No bugs were detected in this PR.

@Luen

Luen commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator Author

Both review points are addressed in 592c0b7. toAbsoluteHttpUrl now resolves same-origin paths against a sentinel base and returns null when the origin changes, and new tests cover backslash and tab escapes and credential stripping. The redundant sanitizeMediaItem is removed. Lint, tests and build pass locally, and CI is green.

🤖 Generated with Claude Code

@Luen
Luen merged commit 5b8c6ea into main Nov 2, 2026
14 checks passed
@Luen
Luen deleted the fix/snyk-undici-picomatch branch November 2, 2026 23:22

This branch was successfully deployed

1 active deployment
Preview — 592c0b7a Deployed Nov 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant